//
//  CALayer+Extension.m
//  FM
//
//  Created by 王方伟 on 2017/11/24.
//  Copyright © 2017年 wfw. All rights reserved.
//

#import "CALayer+Extension.h"

@implementation CALayer (Extension)
#pragma mark 暂停动画
- (void)pauseAnimate{
    CFTimeInterval pausedTime = [self convertTime:CACurrentMediaTime() fromLayer:nil];
    self.speed = 0.0;
    self.timeOffset = pausedTime;
}

#pragma mark 恢复动画
- (void)resumeAnimate{
    CFTimeInterval pausedTime = [self timeOffset];
    self.speed = 1.0;
    self.timeOffset = 0.0;
    self.beginTime = 0.0;
    CFTimeInterval timeSincePause = [self convertTime:CACurrentMediaTime() fromLayer:nil] - pausedTime;
    self.beginTime = timeSincePause;
}
@end
